package com.yimi.yinhepda.db.dao;

import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.support.DatabaseConnection;
import com.yimi.yinhepda.base.BaseApplication;
import com.yimi.yinhepda.db.helper.DbHelper;
import com.yimi.yinhepda.db.table.OffLineUnbindTable;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 离线托盘解绑数据库
 *
 * @author xionggaosheng
 */
public class OffLineUnbindTableDao extends BaseDao<OffLineUnbindTable, Long> {

    public OffLineUnbindTableDao() {
        super(DbHelper.getInstance(BaseApplication.getContext()), OffLineUnbindTable.class);
    }


    public OffLineUnbindTable getFirst() {
        QueryBuilder<OffLineUnbindTable, Long> mQueryBuilder = dao.queryBuilder();
        OffLineUnbindTable offLineUnbindTable = null;
        try {
            offLineUnbindTable = mQueryBuilder.queryForFirst();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return offLineUnbindTable;
    }


    public List<OffLineUnbindTable> queryListByForkliftNo(String forkliftNo) {
        QueryBuilder<OffLineUnbindTable, Long> mQueryBuilder = dao.queryBuilder();

        List<OffLineUnbindTable> offLineUnbindTable = new ArrayList<>();

        try {
            offLineUnbindTable.addAll(mQueryBuilder.where().eq("forkliftNo", forkliftNo).query());
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return offLineUnbindTable;
    }
}
